import { useEffect } from 'react'
import { useSelector } from 'react-redux'
import { View, Button, Text } from '@tarojs/components'
import './index.scss'
import Taro from '@tarojs/taro'
import { activityJoinNotifyApi } from '../../http/Api/activity'

const Message = () => {
  const openid = useSelector((state) => state.user.openid)

  function getMessage() {
    activityJoinNotifyApi(openid)
      .then(res => {
        console.log('获取新消息：', res);
      })
      .catch(err => {
        console.log('获取消息失败：', err)
      })
  }

  useEffect(() => {
    const timer = setInterval(() => {
      getMessage()
    }, 5000);

    return () => {
      clearInterval(timer)
    }
  }, []);

  return (
    <View>
      消息
    </View>
  )
}

export default Message

